/**
 * CopyRight © 2012 USTC SINOVATE SOFTWARE CO.LTD All Rights Reserved.
 */

package com.cmcc.zysoft.infocollection.mobile.service;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.cmcc.zysoft.infocollection.mobile.dao.MAdviseDao;
import com.cmcc.zysoft.infocollection.model.Advise;
import com.starit.common.dao.hibernate.HibernateBaseDao;
import com.starit.common.dao.service.BaseServiceImpl;

/**
 * @author 袁凤建
 * <br />邮箱: yuan.fengjian@ustcinfo.com
 * <br />描述: AdviseService.java
 * <br />版本: 1.0.0
 * <br />日期: 2013-8-12 上午10:12:44
 * <br />CopyRight © 2012 USTC SINOVATE SOFTWARE CO.LTD All Rights Reserved.
 */

@Service
public class MAdviseService extends BaseServiceImpl<Advise, String> {

	@Resource
	private MAdviseDao mAdviseDao;
	
	@Override
	public HibernateBaseDao<Advise, String> getHibernateBaseDao() {
		return this.mAdviseDao;
	}
	
	/**
	 * 反馈意见持久化.
	 * @param userId 用户ID
	 * @param content 意见内容
	 * @param companyId 企业ID
	 * @return map
	 */
	public Map<String, Object> addAdvise(String userId, String content, String companyId) {
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			Advise advise = new Advise();
			advise.setCompanyId(companyId);
			advise.setContent(content);
			advise.setAdviseMan(userId);
			advise.setAdviseDate(new Date());
			this.mAdviseDao.save(advise);
			map.put("status", "1");
		} catch (Exception e) {
			map.put("status", "2");
		}
		return map;
	}
}